package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/canvas"
	"fyne.io/fyne/v2/container"
	"image/color"
)

func main() {
	a := app.New()
	w := a.NewWindow("Snake")
	w.SetContent(setupGame1())
	w.Resize(fyne.NewSize(400, 400))
	w.SetFixedSize(true)
	w.ShowAndRun()
}

func setupGame1() *fyne.Container {
	var segments []fyne.CanvasObject
	// 创建10个小方框
	for i := 0; i < 10; i++ {
		// 创建方框
		r := canvas.NewRectangle(&color.RGBA{G: 0x66, A: 0xff})
		// 指定方框大小
		r.Resize(fyne.NewSize(10, 10))
		// 将方框放到指定位置
		r.Move(fyne.NewPos(190, float32(50+i*10)))
		segments = append(segments, r)
	}

	return container.NewWithoutLayout(segments...)
}
